package com.twu.biblioteca;

import java.io.Serializable;
import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * User: Anbu
 * Date: 9/23/13
 * Time: 4:09 PM
 * To change this template use File | Settings | File Templates.
 */
public class Movie extends ReservableItem {
    private String movieID;
    private String movieName;
    private int year;
    private String directorName;
    private double rating;

    public Movie(String movieID, String movieName, int year, String directorName, double rating) {
        this.movieID = movieID;
        this.movieName = movieName;
        this.year = year;
        this.directorName = directorName;
        this.rating = rating;
    }

    public static Movie buildMovie(String movieID, String movieName, int year, String directorName, double rating) {
        Movie movie = new Movie(movieID, movieName, year, directorName, rating);
        movie.setCopyList(new LinkedList<Copy>());
        return movie;
    }

    public String getMovieID() {
        return movieID;
    }

    public String toString() {
        return getMovieID() + " - " + getMovieName() + " - " + getYear() + " - " + getDirectorName() + " - " + getRatingInString();
    }

    private Serializable getRatingInString() {
        return (getRating() == 0.0 ? "N/A" : getRating());
    }

    private double getRating() {
        return rating;
    }

    private String getDirectorName() {
        return directorName;
    }

    private int getYear() {
        return year;
    }

    private String getMovieName() {
        return movieName;
    }

    @Override
    public boolean equals(Object object) {
        Movie book = (Movie) object;
        return (getMovieID().equals(book.getMovieID()));
    }

    public static Movie getNullMovie() {
        return new NullMovie();
    }

    public boolean isNull() {
        return false;
    }
}
